<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/denglu.css">
    <link rel="stylesheet" href="./css/reset.css">
    <script src="./js/axios.js"></script>
</head>
<body>
    <div class="cc1">
     <div class="cc5">
        <img src="https://cdn.web-global.fds.api.mi-img.com/mcfe--mi-account/static/static/media/banner.4994397e.jpg" alt="">
        </div>
        <div class="cc2">
            <div class="cc3">
                <div class="cc4">
                    <img src="./img/icon-小米归属.png" alt="">
                    <span>小米账号</span>
                </div>

            </div>
            <div class="cc6">
                <div class="cc7">
                    <div class="cc8">
                        <span><a href="">登录</a></span><span><a href="zhuce.html">注册</a></span>
                 
                    </div>  
                       <div class="cc9">
                            <input type="text" class="oipt" name="" id="" >
                            
                            
                        </div>
                        <div class="cc11">
                            <input type="text" class="tipt" name="" id="" >
                            
                            
                        </div>
                        <div class="cc10">
                            <input type="checkbox" class="hipt">
                            <span>已阅读并同意小米帐号 用户协议 和 隐私政策</span>
                        </div>
                        <input type="button" value="登录" class="dd1">
                </div>
            </div>
        </div>
    </div>
    <script>
        let oipt=document.querySelector(".oipt")
        let tipt=document.querySelector(".tipt")
        let hipt =document.querySelector(".hipt")
        let btn=document.querySelector(".dd1")
 
        btn.onclick =async function(){
            if(hipt.checked){
                let username=oipt.value
                let password=tipt.value
                let data={username,password}
                let url="http://jx.xuzhixiang.top/ap/api/login.php";
                let r=await axios.get(url,{params:data});
                console.log(r.data);
                alert(r.data.msg)
                if(r.data.code==1){
                    localStorage.setItem("uid",r.data.data.id)
                    localStorage.setItem("token",r.data.data.token)
                    localStorage.setItem("username",r.data.data.username)
                    location.href="首页.html"
                }
            }
            else{
                alert("错误")
            }
        }
    </script>
</body>
</html>